<script setup lang="ts">
import Header from '@/components/layout/Header.vue'
import { useAuthStore } from '@/store/modules/auth'
import { onMounted } from 'vue'
import Toast from '@/components/ui/Toast.vue'

const authStore = useAuthStore()

onMounted(() => {
  authStore.checkAuth()
  authStore.refreshToken()
  //定时刷新token
  setInterval(() => {
    if(localStorage.getItem("token")){
      authStore.refreshToken()
    }
  }, 1000*60*30)

})
</script>

<template>
  <Toast />
  <Header />
  <main class="main-content">
    <router-view />
  </main>
</template>

<style lang="scss">
// 全局样式
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
    'Open Sans', 'Helvetica Neue', sans-serif;
  line-height: 1.5;
  color: #333;
}

.main-content {
  min-height: calc(100vh - 64px);
  margin-top: 64px;
}
</style>
